package dao

import (
	"gitee.com/shuwenhe/shuwen/encoding/json/encode.go/Marshal2/model"
	"gitee.com/shuwenhe/shuwen/encoding/json/encode.go/Marshal2/util"
)

func GetActors() ([]*model.Actor, error) {
	sql := "select id,name from actor"
	rows, err := util.Db.Query(sql)
	if err != nil {
		return nil, err
	}
	var actors []*model.Actor
	for rows.Next() {
		actor := &model.Actor{}
		err := rows.Scan(&actor.ID, &actor.Name)
		if err != nil {
			return nil, err
		}
		actors = append(actors, actor)
	}
	return actors, nil
}
